<html>
<head>
    <title>qBase addEvent Tester</title>
    <script>imagePath='../';wrroot='../';scriptPath='../';contextPath='';</script>
    <script src="../qCore.js"></script>
    <script src="../qBase.js"></script>
    <style>
    </style>
    <script>
        bDebug=true
        MyObj=QEventDomain.extend({
             className :"MyObj"
          // Main Ctor
            ,base_constr : function mapcore_base_constr(name){
        //      pc(">>>>")
                var t=this
                
                try {
                    t.name = name
                    
                }catch(exc){  
                    qErr(
                        t.className+" Base Constructor Failed: "
                        ,exc
                        ,{argDump    :q$.dumpArgs }
                    )
                }
                
        //      pc("<<<<")
            }
            ,doSomething: function myobj_doSomething(s){
                debug(s)
            }
            
            ,e_div1_click: function myobj_e_div1_click(e){
                debug("called - "+e)   
            }
            ,e_general_mousedown: function myobj_e_general_mousedown(e){
                var o=e.target
                pc(
                    "Called"
                   +"\n e = "+e
                   +"\n o = "+o
                   +"\n dump(o):\n"+s$.pad(qObjDump(o))
                ) 
            }
            ,constructor: function MyObj(name){this.base_constr(name)}  
        });__initDefQClient()
    
    
        
        function bodyLoaded(){
            var o
            obj = new MyObj("testObj")
//            obj.doSomething("cool")
           // Good Tests
//            goodEvent_test();
//            goodEvent_JDat_test();
//            goodEvent_win_test();
            
          // Bad Testers (error expected)
//            badEvent_doc_test();
//            badEvent_nofunc_test()

            
        }
        
      /* GOOD addEvent TESTERS */
        function goodEvent_test(){
            o=getElem("div1")
            obj.addEvent(o,"click",obj.e_div1_click)
        }
        
        function goodEvent_JDat_test(){
            o=getElem("div1")
            obj.addEvent(o,"click",obj.e_div1_click)
            
            pc(
                "Testing jDat"
               +"\n o = "+o
               +"\n dump o:\n"+s$.pad(qObjDump(o))
               +"\n jDat:\n"+s$.pad(o.jDat)
               +"\n lang:\n"+s$.pad(o.lang)
            )
        }
        
      /* BAD addEvent TESTERS */
        function goodEvent_win_test(){
            obj.addEvent(_w,"mousedown",obj.e_general_mousedown)
        }
        function badEvent_doc_test(){
            obj.addEvent(_d,"mousedown",obj.e_general_mousedown)
        }
        function badEvent_nofunc_test(){
            o=getElem("div1")
            obj.addEvent(o,"click",{})
        }

        
        
        
        
    </script>
</head>

<body>
    <div id=div1 style='border: 1px solid #777' lang="{var1: 'var1val1', _lang: 'myLang1'}">DIV 1</div>
    
	<script>
        bConsole=true; __qcOpts={cb:true, t:0, w: 600, h: 500}
	    _SCR_START=" bodyLoaded();"; function __start() {try{if(bConsole){startCons(__qcOpts); _w.consoleLoaded = function consoleLoaded(){ setTimeout(_SCR_START,50) }}else{eval(_SCR_START)}}catch(e){debugErr(e)}};__start()
    </script>
</body>
</html>